package cn.aitrox.ry.service.auth.service.impl;

import cn.aitrox.ry.service.auth.dao.AuthResourceDao;
import cn.aitrox.ry.service.auth.dto.resource.out.AuthResourceDetailDto;
import cn.aitrox.ry.service.auth.entity.AuthResourceEntity;
import cn.aitrox.ry.service.auth.service.AuthResourceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

@Service
public class AuthResourceServiceImpl implements AuthResourceService {

    @Autowired
    private AuthResourceDao authResourceDao;

    @Override
    public List<AuthResourceDetailDto> all() {
        List<AuthResourceEntity> all = authResourceDao.findAll();
        return all.stream().map(x -> new AuthResourceDetailDto(x.getId(), x.getCode(), x.getParentId(), x.getName(), x.getType(), x.getDescription(), x.getApiUri(), x.getApiMethod(), x.getCreateTime(), x.getUpdateTime(), null)).collect(Collectors.toList());
    }
}
